package com.ltu.util.common;

import cn.hutool.core.util.ArrayUtil;
import java.util.List;

public class SqlUtils {

    /**
     * 将id列表转换成in查询语句
     * @param idList
     * @return
     */
    public static String getInSeq(List<String> idList) {
        if (ArrayUtil.isEmpty(idList)) return null;
        StringBuilder sbStr = new StringBuilder("'");
        sbStr.append(StrUtils.arrayToStr(idList, ','));
        sbStr.append("'");
        return sbStr.toString();
    }

    /**
     * 将多id的字符串转换成in查询语句
     * @param idString
     * @return
     */
    public static String getInSeq(String idString) {
        if (StrUtils.isTrimNull(idString)) return idString;
        List<String> idList = IdsStrToListUtils.getStringList(idString);
        StringBuilder sbStr = new StringBuilder("'");
        sbStr.append(StrUtils.arrayToStr(idList, ','));
        sbStr.append("'");
        return sbStr.toString();
    }
}
